package com.wy.powerbuilder.controller.ld;

import com.github.pagehelper.PageInfo;
import com.wy.powerbuilder.entity.ld.Sys_log;
import com.wy.powerbuilder.service.ld.LogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
public class LogController {
    @Autowired
    private LogService logService;
    @RequestMapping("log")
    public String log(Model model,Integer pageNo,String logmin,String logmax,String name){
        System.out.println("aa"+name);
        if(logmin==""){
            logmin=null;
        }
        if(logmax==""){
            logmax=null;
        }
       PageInfo<Sys_log> logs=logService.pageAll(pageNo,logmin,logmax,name);
        model.addAttribute("logs",logs);
        return "system-log";
    }
    @ResponseBody
    @RequestMapping("addLog")
    public String addLog(int count,String name,String port,String ip,String time,String address){
        Sys_log sys_log=new Sys_log();
        sys_log.setCount(count);
        sys_log.setName(name);
        sys_log.setPort(port);
        sys_log.setIp(ip);
        sys_log.setTime(time);
        sys_log.setAddress(address);
        logService.addLog(sys_log);
        return "";
    }
}
